//
//  HomeController.m
//  test
//
//  Created by 科迈捷 on 2017/3/28.
//  Copyright © 2017年 科迈捷. All rights reserved.
//

#import "HomeController.h"

@interface HomeController () {
    NSArray *_titles;
}

@end

@implementation HomeController

- (void)viewDidLoad {
    [super viewDidLoad];
    _titles = @[@"Core Animation",@"Net"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _titles.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *identifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.textLabel.text = _titles[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *title = [_titles[indexPath.row] stringByReplacingOccurrencesOfString:@" " withString:@""];
    UIViewController *vc = [NSClassFromString([NSString stringWithFormat:@"%@Controller",title]) new];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
